home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / cutils.arc / SOUND.ASM < prev    next >
Assembly Source File  |  1985-08-30  |  2KB  |  47 lines

  1.                         TITLE   SOUND ROUTINE FOR LATTICE
  2.                         NAME    SOUNDER
  3.                         INCLUDE DOS.MAC
  4.  
  5. COMMENT #
  6.                 AUTHOR          Jon Wesener
  7.                 DATE            7 / 19 / 85
  8.                 PURPOSE         This routine will let you specify a
  9.                                 frequency and duration in .01 seconds.
  10.         #
  11.  
  12.                 PSEG
  13.                 PUBLIC  SOUND
  14. ; Sound lets you generate a frequency with a given duration in hundredths
  15. ; of seconds.
  16. ;  sound(frequency, duration);
  17. ; RETURN:       sound
  18.  
  19. SOUND           PROC    NEAR
  20.                 push    bp
  21.                 mov     bp, sp
  22.                 mov     di, [bp+4]
  23.                 mov     bx, [bp+6]
  24.                 mov     al, 0b6h        ; write timer mode register
  25.                 out     43h, al
  26.                 mov     dx, 14h         ; timer divisor=
  27.                 mov     ax, 4f38h       ; 1331000/ frequency
  28.                 div     di
  29.                 out     42h, al         ; write timer 2 count low byte
  30.                 mov     al, ah
  31.                 out     42h, al         ; write timer 2 count high byte
  32.                 in      al, 61h         ; get current port B setting
  33.                 mov     ah, al
  34.                 or      al, 3           ; turn speaker on
  35.                 out     61h, al
  36. wait:           mov     cx, 2801        ; wait 10 milliseconds
  37. spkr_on:        loop    spkr_on
  38.                 dec     bx              ; speaker on count expired
  39.                 jnz     wait            ; no. keep it on!
  40.                 mov     al, ah          ; otherwise restore it.
  41.                 out     61h, al
  42.                 pop     bp
  43.                 ret
  44. SOUND           ENDP
  45.                 ENDPS
  46.                 END
  47.